﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RolesEditControl.ascx.cs"
    Inherits="WebApplication.Controls.Security.Roles.RolesEditControl" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="AvailableFacultiesGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="AvailableFacultiesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ChosenFacultiesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ChosenFacultiesGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="AvailableFacultiesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ChosenFacultiesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadScriptBlock runat="server" ID="scriptBlock">

    <script type="text/javascript">
                <!--
        alert('halinka');
        function onRowDropping(sender, args) {
            alert('halinka');
            if (sender.get_id() == "<%=AvailableFacultiesGrid.ClientID %>") {
                var node = args.get_destinationHtmlElement();
                if (!isChildOf('<%=ChosenFacultiesGrid.ClientID %>', node) && !isChildOf('<%=AvailableFacultiesGrid.ClientID %>', node)) {
                    args.set_cancel(true);
                }
            }
            else if (sender.get_id() == "<%=ChosenFacultiesGrid.ClientID %>") {
                var node = args.get_destinationHtmlElement();
                if (!isChildOf('<%=AvailableFacultiesGrid.ClientID %>', node) && !isChildOf('<%=ChosenFacultiesGrid.ClientID %>', node)) {
                    args.set_cancel(true);
                }
            }
        }

        function isChildOf(parentId, element) {
            while (element) {
                if (element.id && element.id.indexOf(parentId) > -1) {
                    return true;
                }

                element = element.parentNode;
            }
            return false;
        }
                    -->
    </script>

</telerik:RadScriptBlock>
<p>
    <asp:Label ID="Label1" runat="server" Text="Nazwa roli:"></asp:Label>
    <asp:TextBox ID="RoleNameTextBox" runat="server"></asp:TextBox>
    <asp:Label ID="Label2" runat="server" Text="Opis roli: "></asp:Label>
    <asp:TextBox ID="RoleDescriptionTextBox" runat="server"></asp:TextBox>
    </p>
    <p>
        <asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="Update" />
        <asp:Button ID="InsertButton" runat="server" Text="Insert" CommandName="PerformInsert" />
        <asp:Button ID="CancelButton" runat="server" Text="Cancel" CommandName="Cancel" />
     </p>
        <telerik:RadGrid ID="AvailableFacultiesGrid" runat="server" GridLines="None" OnRowDrop="AvailableFacultiesOnRowDrop"
            OnNeedDataSource="AvailableFacultiesNeedDataSource" AllowFilteringByColumn="True"
            AllowPaging="True" AllowSorting="True" Skin="Windows7">
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" CommandItemDisplay="Top">
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True"
                        SortExpression="Id" UniqueName="Id">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                        UniqueName="Name">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"
                        UniqueName="Description">
                    </telerik:GridBoundColumn>
                </Columns>
                <CommandItemTemplate>
                    Dostępne funkcjonalności
                </CommandItemTemplate>
            </MasterTableView>
            <ClientSettings AllowRowsDragDrop="True">
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
                <ClientEvents OnRowDropping="onRowDropping" />
            </ClientSettings>
        </telerik:RadGrid>
        <p>
            <br />
        </p>
        <telerik:RadGrid ID="ChosenFacultiesGrid" runat="server" GridLines="None" OnRowDrop="ChosenFacultiesOnRowDrop"
            OnNeedDataSource="ChosenFacultiesNeedDataSource" Skin="Windows7">
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" CommandItemDisplay="Top">
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True"
                        SortExpression="Id" UniqueName="Id">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                        UniqueName="Name">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"
                        UniqueName="Description">
                    </telerik:GridBoundColumn>
                </Columns>
                <CommandItemTemplate>
                    Wybrane funkcjonalności
                </CommandItemTemplate>
            </MasterTableView>
            <ClientSettings AllowRowsDragDrop="True">
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
                <ClientEvents OnRowDropping="onRowDropping" />
            </ClientSettings>
        </telerik:RadGrid>
